﻿using Common;
using Common.SerializationHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeliveryManage.DAL
{
    public partial class Sys_Config
    {
        public Sys_Config()
        { }

        private static object lockHelper = new object();

        /// <summary>
        ///  读取站点配置文件
        /// </summary>
        public DeliveryManage.Model.Sys_Config loadConfig()
        {
            DeliveryManage.Model.Sys_Config model = CacheHelper.Get<DeliveryManage.Model.Sys_Config>(DTKeys.SYS_CONFIG);
            if (model == null)
            {
                CacheHelper.Insert(DTKeys.SYS_CONFIG, (DeliveryManage.Model.Sys_Config)SerializationHelper.Load(typeof(DeliveryManage.Model.Sys_Config),Utils.GetXmlMapPath(DTKeys.SYS_XML_CONFING)));
                model = CacheHelper.Get<DeliveryManage.Model.Sys_Config>(DTKeys.SYS_CONFIG);
            }
            return model;
        }
       
        /// <summary>
        /// 写入站点配置文件
        /// </summary>
        public bool saveConifg(DeliveryManage.Model.Sys_Config model)
        {
            lock (lockHelper)
            {
                SerializationHelper.Save(model, Utils.GetXmlMapPath(DTKeys.SYS_XML_CONFING) );
            }
            return true;
        }
    }
}
